package org.shijiagen.clients;

import org.shijiagen.param.ProductCollectParam;
import org.shijiagen.param.ProductIdParam;
import org.shijiagen.param.ProductSaveParam;
import org.shijiagen.pojo.Product;
import org.shijiagen.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@FeignClient(name = "product-service",url = "http://localhost:3004")
public interface ProductClient {

    /**
     * 获取全部商品
     * @return
     */
    @GetMapping("product/list")
    List<Product> allList();

    @PostMapping("product/collect/list")
    List<Product> productListByIds(@RequestBody @Validated ProductCollectParam productCollectParam);

    @PostMapping("product/cart/detail")
    Product cartProductDetail(@RequestBody @Validated ProductIdParam productIdParam);

    @PostMapping("product/cart/list")
    List<Product> cartProductByIds(@RequestBody @Validated ProductCollectParam productCollectParam);

    @PostMapping("product/admin/count")
    Long adminCount(@RequestBody Integer categoryId);

    @PostMapping("product/admin/save")
    R adminSave(@RequestBody ProductSaveParam productSaveParam);

    @PostMapping("product/admin/update")
    R adminUpdate(@RequestBody Product product);

    @PostMapping("product/admin/remove")
    R adminRemove(@RequestBody Integer productId);
}
